home *** CD-ROM | disk | FTP | other *** search
/ Alles Voor Internet / Tout Pour Internet / alles voor internet.iso / MacInternet™ / Telnet / NCSA / tn3270 2.4d7 source / tn3270 / prt.c < prev    next >
Text File  |  1992-04-17  |  4KB  |  147 lines

  1. /*
  2.  *  tn3270 for the Macintosh Source Code
  3.  *  Brown University Computing and Information Services
  4.  *  Version 2.4d7  April, 1992
  5.  *  Copyright (c) 1988, 1989, 1990, 1991, 1992 by Brown University and by
  6.  *  Peter John DiCamillo.
  7.  *
  8.  *  Permission is granted to any individual or institution to use, copy,
  9.  *  or redistribute the binary version of this software and its
  10.  *  documentation provided this notice and the copyright notices are
  11.  *  retained.  Permission is granted to any individual or non-profit
  12.  *  institution to use, copy, modify, or redistribute the source files
  13.  *  of this software provided this notice and the copyright notices are
  14.  *  retained.  This software may not be distributed for profit, either
  15.  *  in original form or in derivative works, nor can the source be
  16.  *  distributed to other than an individual or a non-profit institution.
  17.  *  Any  individual or group interested in seeing and/or using these
  18.  *  source files but who are prevented from doing so by the above
  19.  *  constraints should contact Don Wolfe, Assistant Vice-President for
  20.  *  Computer Systems at Brown University, (401) 863-7250, for possible
  21.  *  software licensing of the source developed at Brown.
  22.  *
  23.  *  Brown University and Peter John DiCamillo make no representations
  24.  *  about the suitability of this software for any purpose.
  25.  *
  26.  *  BROWN UNIVERSITY AND PETER JOHN DICAMILLO GIVE NO WARRANTY, EITHER
  27.  *  EXPRESS OR IMPLIED, FOR THE PROGRAM AND/OR DOCUMENTATION PROVIDED,
  28.  *  INCLUDING, WITHOUT LIMITATION, WARRANTY OF MERCHANTABILITY AND
  29.  *  WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE.
  30.  *
  31.  */
  32.  
  33. #if !defined(USEDUMP)
  34.     #include "maclib.h"
  35.     #include "termdef.h"
  36.     #include "tn3270funcs.h"
  37.     #include "globals.h"
  38. #else
  39.     #pragma load "tn3270DumpFile"
  40. #endif
  41.  
  42. #pragma segment vmxfer
  43.  
  44. void pgsetup(void)
  45. {
  46. if (hPrint == 0) {
  47.     SysBeep(1);
  48.     return;
  49.     }
  50. if (prtinit == 0) {
  51.     PrOpen();
  52.     if (PrError() != noErr) {
  53.         SysBeep(1);
  54.         return;
  55.         }
  56.     PrintDefault(hPrint);
  57.     prtinit = 1;
  58.     }
  59. PrValidate(hPrint);        /* in case user changed print drivers */
  60. PrStlDialog(hPrint);
  61. }
  62.  
  63. void prscreen(cnr *cp)
  64. {
  65. TPPrPort prtport;
  66. GrafPtr gp;
  67. TPrStatus prStatus;
  68.  
  69. if (hPrint == 0) {
  70.     SysBeep(1);
  71.     return;
  72.     }
  73. if (prtinit == 0) {
  74.     PrOpen();
  75.     if (PrError() != noErr) {
  76.         SysBeep(1);
  77.         return;
  78.         }
  79.     PrintDefault(hPrint);
  80.     prtinit = 1;
  81.     }
  82. PrValidate(hPrint);        /* in case user changed print drivers */
  83. arrowcursor();
  84. if (!PrJobDialog(hPrint)) return; 
  85.  
  86. /* main printing code (not loop, since only one page) */
  87. GetPort(&gp);
  88. setdoctitle("3270 Screen Dump");
  89. prtport = PrOpenDoc(hPrint, 0L, 0L);
  90. if (PrError() == noErr) {
  91.     PrOpenPage(prtport, 0L);        /* start new page */
  92.     if (PrError() == noErr) prtdraw(cp);
  93.     PrClosePage(prtport);
  94.     }
  95. PrCloseDoc(prtport);
  96. if (((*hPrint)->prJob.bJDocLoop == bSpoolLoop) && (PrError() == noErr))
  97.     PrPicFile(hPrint, 0L, 0L, 0L, &prStatus);
  98. if (PrError() != noErr) stoperr(305, cp);
  99. SetPort(gp);
  100. }
  101.  
  102. void prtdraw(cnr *cp)
  103. {
  104. char colorsave;
  105. GrafPtr gp;
  106.  
  107. TextFont(cp->stdfont);
  108. PicComment(155, 0, 0L);        /* line layout off */
  109.  
  110.     /* set constants for 12-point, and if page is not big enough,
  111.        use 9-point instead                                        */
  112. setmode(cp->cur_rows, cp->cur_cols, 12, 0, cp);
  113. TextSize(12);
  114. GetPort(&gp);
  115. if ((cp->hpixsize > (gp->portRect).right) ||
  116.     (cp->vpixsize > (gp->portRect).bottom)) {
  117.     setmode(cp->cur_rows, cp->cur_cols, 9, 0, cp);
  118.     TextSize(9);
  119.     }
  120.  
  121.     /* set colormac flag according to printing grafport */
  122. colorsave = colormac;
  123. colormac = ((gp->portBits.rowBytes & 0xc000) == 0xc000);
  124. writescr(1, cp);
  125.  
  126.     /* restore settings by calling setmode */
  127. setmode(cp->cur_rows, cp->cur_cols, cp->cur_ptsize, cp->cs.windmax, cp);
  128.  
  129.     /* restore colormac flag */
  130. colormac = colorsave;
  131. }
  132.  
  133. void setdoctitle(unsigned char *s)
  134. {
  135. WindowPtr wp;
  136. unsigned char titlesave[256];
  137.  
  138. wp = FrontWindow();
  139. if (wp == 0) return;
  140. GetWTitle(wp, titlesave);
  141. c2pstr(s);
  142. SetWTitle(wp, s);
  143. p2cstr(s);
  144. PrValidate(hPrint);
  145. SetWTitle(wp, titlesave);
  146. }
  147.